package com.itheima.controller;

import com.itheima.pojo.*;
import com.itheima.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;


    @PostMapping("/login")
    public Result login(@RequestBody User user){
        UserLoginVo vo = userService.login(user);
        Result result = new Result();
        if(vo==null){
            result.setMsg("账号密码错误");
            result.setCode(401);
            return result;
        }
        result.setData(vo);
        result.setCode(200);
        return result;
    }




    @GetMapping("/page")
    public UserPage<User> page(UserDTO userDTO){
        return userService.list(userDTO);
    }






}
